package com.xframe.xdal.core.serialize.proc;

import java.util.HashMap;
import java.util.Map;
/**
 * 功能描述:序列化工厂
 *
 * @author xufeng
 * @version 1.0
 * @date 2022-09-28
 */
public class SerializeProcFactory {

    /**
     * 私有工厂
     */
    private static Map<String, ISerializeProc> innerMap = new HashMap<>();
    /**
     * 序列化构造函数
     * @param className 类型名称
     * @param args 参数
     *
     * @return ISerializeProc序列化器
     */
    public static ISerializeProc build(String className,String args){
        try {
            if (!innerMap.containsKey(className)) {
                Class type = Class.forName(className);
                ISerializeProc proc = (ISerializeProc) type.newInstance();
                if(proc != null) {
                    innerMap.put(className, proc);
                }
            }
            return innerMap.get(className);
        }catch (Exception e){
            return null;
        }
    }
}
